<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./css/index.css">
</head>

<body>按下F12打开控制台
    <div id="tree">
        <div id="tree1"></div>
        <div id="tree2"></div>
    </div>
    <script src="./js/index.js" type="module"></script>
    <script>
        //创建WebSocket实例
        const socket = new WebSocket("ws://127.0.0.1:8089/socketTest")

        //监听服务是否链接
        socket.addEventListener('open', (data) => {
            // console.log('WebSocket 链接成功', data);
        })
        //如果收到服务器发来的消息
        socket.addEventListener('message', (e) => {
            console.log('需要更新', e)
            socket.close()
            setTimeout(() => {//等待tsc之后再修改
                location.reload()
            }, 500);
        })
    </script>
</body>

</html>